<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>交互式开关按钮</title>
    <link rel="stylesheet" href="./18-交互式开关按钮.css">
</head>
<style>
	* {
	    margin: 0;
	    padding: 0;
	}
	
	body {
	    min-height: 100vh;
	    display: flex;
	    justify-content: center;
	    align-items: center;
	    background: linear-gradient(200deg, #e4efe9, #93a5cf);
	}
	
	.container {
	    width: 500px;
	    height: 320px;
	    background-color: #382f45;
	    border-radius: 20px;
	    display: flex;
	    flex-direction: column;
	    justify-content: center;
	    align-items: center;
	    box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.2);
	    padding: 0 15px;
	}
	
	p {
	    width: 80%;
	    color: #fff;
	    font-size: 50px;
	    letter-spacing: 5px;
	}
	
	.input-box {
	    width: 80%;
	    display: flex;
	    justify-content: space-between;
	    margin-top: 50px;
	}
	
	.input-box label {
	    position: relative;
	    cursor: pointer;
	    display: flex;
	    align-items: center;
	    font-size: 32px;
	    color: #fff;
	    letter-spacing: 5px;
	}
	
	.input-box label span {
	    position: relative;
	    display: inline-block;
	    width: 30px;
	    height: 30px;
	    margin-right: 15px;
	    transition: 0.5s;
	}
	
	.input-box label span::before {
	    content: "";
	    position: absolute;
	    left: 0;
	    bottom: 0;
	    width: 100%;
	    height: 4px;
	    background-color: #fff;
	    box-shadow: 0 -26px 0 #fff;
	    transition: 0.5s;
	}
	
	.input-box label span::after {
	    content: "";
	    position: absolute;
	    left: 0;
	    bottom: 0;
	    width: 4px;
	    height: 100%;
	    background-color: #fff;
	    box-shadow: 26px 0 0 #fff;
	    transition: 0.5s;
	}
	
	.input-box label input:checked~span.yes::before {
	    background-color: #0f0;
	    box-shadow: none;
	}
	
	.input-box label input:checked~span.yes::after {
	    background-color: #0f0;
	    box-shadow: none;
	    height: 55%;
	}
	
	.input-box label input:checked~span.yes {
	    transform: rotate(-45deg) translate(2px, -10px);
	}
	
	.input-box label input:checked~span.no::before {
	    background-color: #f00;
	    box-shadow: none;
	    transform: rotate(-45deg) translate(7px, -8px);
	}
	
	.input-box label input:checked~span.no::after {
	    background-color: #f00;
	    box-shadow: none;
	    transform: rotate(-45deg) translate(7px, 11px);
	}
	
	.input-box input {
	    display: none;
	}
</style>
<body>
    <div class="container">
        <p>会给我三连吗？</p>
        <div class="input-box">
            <label>
                <input type="radio" name="yes_no">
                <span class="yes"></span>
                必须滴
            </label>
            <label>
                <input type="radio" name="yes_no">
                <span class="no"></span>
                下次一定
            </label>
        </div>
    </div>
</body>

</html>